package mvc.controller;

import mvc.model.pojos.OrderBean;
import mvc.model.pojos.UserBean;
import mvc.model.service.OrderService;
import mvc.model.service.impl.OrderServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "CenterServlet",urlPatterns = "/center")
public class CenterServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        OrderService orderService = new OrderServiceImpl();
        UserBean user = (UserBean) request.getSession().getAttribute("user");
        List<OrderBean> dfk = orderService.queryStatus(user.getUid(), "待付款");
        List<OrderBean> dfh = orderService.queryStatus(user.getUid(), "待发货");
        request.getSession().setAttribute("dfk", dfk);
        request.getSession().setAttribute("dfh", dfh);
        response.sendRedirect("people-center.jsp");
    }
}
